package com.jiepu.homework.module5.exercise5;

public class Account { // 账户类
	
	protected double balance; // 余额
	
	// 账户对象的初始化逻辑，必须要提供余额
	public Account(double balance) {
		this.balance = balance;
	}
	
	public double getBalance() { // 查询余额
		return this.balance;
	}
	
	public boolean deposit(double amount) { // 存钱
		balance += amount;
		return true;
	}
	
	public boolean withdraw(double amount) { // 取钱
		if (amount > balance) {
			System.out.println("余额不足，取款失败！");
			return false;
		}
		
		balance -= amount;
		return true;
	}
	
}
